/*
 *@Author: 张楚
 *@Date: 2021-07-28 20:25:37
 *@Description:懒加载 + getview
*/
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:totaldemo/getx/dependency_lazyPut_nextpage.dart';
import 'package:totaldemo/getx/controller.dart';

class LazyPutPage extends StatelessWidget {
  LazyPutPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("懒加载+ Getview"),
      ),
      body: Center(
        child: Column(
          children: [
            GetX<LazyController>(
              init: Get.find<LazyController>(),
              initState: (_) {},
              builder: (_) {
                return Text('value -> ${_.count}');
              },
            ),
            Divider(),

            // 按钮
            ElevatedButton(
              onPressed: () {
                Get.find<LazyController>().add();
              },
              child: Text('add'),
            ),

            // 跳转
            ElevatedButton(
              onPressed: () {
                Get.to(LazyPutNextPage());
              },
              child: Text('Next GetView Page1'),
            ),
          ],
        ),
      ),
    );
  }
}
